#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve()
{
    int n;
    cin >> n;
    if (n % 4 == 0)
        cout << n << endl;
    else if (n % 4 == 1)
        cout << 0 << endl;
    else if (n % 4 == 2)
        cout << n + 1 << endl;
    else
        cout << 1 << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}